#include<iostream>
using namespace std;

void preorder(string mid, string end) {
    if(mid.length() == 0) return;
    char root = end[end.length() - 1];
    cout << root;
    int pos = mid.find(root);
    preorder(mid.substr(0, pos), end.substr(0, pos));
    preorder(mid.substr(pos + 1), end.substr(pos, end.length() - pos - 1));
}

int main() {
    string mid, end;
    cin >> mid >> end;
    preorder(mid, end);
    return 0;
} 